$.ajax({
	url:'/js/structure_product.json',
	dataType:'JSON',
	async:false,
	success:function(data){
		inlay= data.inlays;
		inlay_category=data.inlays_category;
		gem=data.gems;
		gem_category=data.gems_category;
		parcel=data.parcels;
		parcel_category=data.parcels_category;
		emerald=data.emeralds;
		emerald_category=data.emeralds_category;
		emerald_type_category=data.emeralds_type_category;
		stock=data.stocks;
		prime_gold=data.prime_golds;
		prime_gold_category=data.prime_golds_category;
        inlaysetting=data.inlays_settings;
        inlaysetting_category=data.inlays_settings_category;
	},
	error:function(XMLHttpRequest,a,b){
       	myApp.alert(b);
	}
});
//转换成对应的字段
function GetText(json_TYPE,type,val,na){
	var valText="";
	var jsonType;
	if(json_TYPE=="stocks"){		
		jsonType=stock;
	}else if(json_TYPE=="parcels"){
		jsonType=parcel;
	}else if(json_TYPE=="inlays"){
		jsonType=inlay;
	}else if(json_TYPE=="gems"){
		jsonType=gem;
	}else if(json_TYPE=="emeralds"){
		jsonType=emerald;
	}else if(json_TYPE=="prime_golds"){
		jsonType=prime_gold;
	}else if(json_TYPE=="inlaysettings"){
        jsonType=inlaysetting;
    }
	if(jsonType[type][na]){
		var len=jsonType[type][na].length;
		for(var i=0;i<len;i++){
			if(val==jsonType[type][na][i][0]){
				valText= jsonType[type][na][i][1];
				break;
			}
		}
		if(valText==""){
			if(na=="Status"){
				valText="-";
			}else{
				valText=val;
			}
		}
		return _(valText)
	}else{
		return val==""?"-":val;
	}
}

//裸钻形状转图标
function getShape(val) {
    var imgHtml='';
    switch (val){
        case '圆形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -2px -1px;"></div>';
            break;
        case '椭圆形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -104px -1px;"></div>';
            break;
        case '垫形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -226px -1px;"></div>';
            break;
        case '梨形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -127px -1px;"></div>';
            break;
        case '心形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -172px -1px;"></div>';
            break;
        case '马眼形':
            imgHtml='<div style="height: 27px;width: 27px;background: url('+'../images/shapeNew.png'+');background-position: -149px -1px;"></div>';
            break;
        case '公主方':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -31px -1px;"></div>';
            break;
        case '祖母绿':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -56px -1px;"></div>';
            break;
        case '雷迪恩':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -80px -1px;"></div>';
            break;
        case '三角形':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -198px -1px;"></div>';
            break;
        case '其它':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -253px -1px;"></div>';
            break;
        case '其他':
            imgHtml='<div style="height: 27px;width: 29px;background: url('+'../images/shapeNew.png'+');background-position: -253px -1px;"></div>';
            break;
        default:
            break;
    }
    return imgHtml;

}
//统包成品 形状转图标
function getBicon(val){
    var imgHtml='';
    switch (val){
        case '圆形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -26px -7px;"></div>';
            break;
        case '心形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -224px -7px;"></div>';
            break;
        case '椭圆形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -146px -7px;"></div>';
            break;
        case '梨形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -172px -7px;"></div>';
            break;
        case '垫形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -289px -7px;"></div>';
            break;
        case '祖母绿':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -118px -7px;"></div>';
            break;
        case '马眼形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -196px -7px;"></div>';
            break;
        case '公主方':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -54px -7px;"></div>';
            break;
        case '梯形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -315px -7px;"></div>';
            break;
        case '直方':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -371px -7px;"></div>';
            break;
        case '其它':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -342px -7px;"></div>';
            break;
        case '其他':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -342px -7px;"></div>';
            break;
        case '组合形':
            imgHtml='<div style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -290px -7px;"></div>';
            break;
        default:
            break;
    }
    return imgHtml;

}

//成品订单 形状转图标
function getBiconRing(val){
    var imgHtml='';
    switch (val){
        case '圆形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -26px -7px;"></b>';
            break;
        case '心形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -224px -7px;"></b>';
            break;
        case '椭圆形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -146px -7px;"></b>';
            break;
        case '梨形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -172px -7px;"></b>';
            break;
        case '垫形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -289px -7px;"></b>';
            break;
        case '祖母绿':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -118px -7px;"></b>';
            break;
        case '马眼形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -196px -7px;"></b>';
            break;
        case '公主方':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -54px -7px;"></b>';
            break;
        case '梯形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -315px -7px;"></b>';
            break;
        case '直方':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -371px -7px;"></b>';
            break;
        case '其它':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -342px -7px;"></b>';
            break;
        case '其他':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -342px -7px;"></b>';
            break;
        case '组合形':
            imgHtml='<b style="padding: 0; height: 29px;width: 32px;background: url('+'../../images/biconNew.png'+');background-position: -290px -7px;"></b>';
            break;
        default:
            break;
    }
    return imgHtml;

}

 
//类型
function GetCategory(json_TYPE,val){
	if(json_TYPE=="parcels"){
		var text = parcel_category[val];
	}else if(json_TYPE=="inlays"){
		var text = inlay_category[val];
	}else if(json_TYPE=="gems"){
		var text = gem_category[val];
	}else if(json_TYPE=="emeralds"){
		var text = emerald_category[val];
	}else if(json_TYPE=="prime_golds"){
		var text=prime_gold_category[val];
	}else if(json_TYPE=="inlaysettings"){
        var text=inlaysetting_category[val];
    }
	return _(text);	
}
//翡翠类型
function getEmeraldType(type,val,na){//GetText2
	var valText="";
	var jsonType=emerald_type_category
	if(jsonType[type][na]){
		var len=jsonType[type][na].length;
		for(var i=0;i<len;i++){
			if(val==jsonType[type][na][i][0]){
				valText= jsonType[type][na][i][1];
				break;
			}
		}
		if(valText==""){
			valText=val;
		}
		return _(valText);
	}else{
		return val==""?"-":val;
	}	
}

//人民币价格不显示小数点
function formatRMBPrice(val){
	var _val =Number(val);
	if(_val!=NaN){
		_val=_val.toFixed(0);
		return Number(_val);
	}else{
		return 0;
	}	
}
//美元价格显示
function formatUSDPrice(val){
	var _val =Number(val);
	if(_val!=NaN){
		_val=_val.toFixed(1);
		return Number(_val);
	}else{
		return 0;
	}
}
//形状格式化(公共JS方法)
function ShpaeFormat(shapeValue) {
    var dic = ["其他", "圆形", "公主方", "祖母绿", "雷迪恩", "椭圆形", "梨形", "马眼形", "心形", "三角形", "垫形", "其他"]
    if (dic.length >= shapeValue && shapeValue > 0) {
        return _(dic[shapeValue]);
    }
    return _(dic[0]);
}
//返回彩钻的首字母
function ColorFormat(wrods) {
    var ws = wrods.split(' ');
    var lw = "";
    for (var i = 0; i < ws.length; i++) {
        lw = lw + ws[i].substring(0, 1).toUpperCase()
    }
    if (lw == "")
        return wrods
    return lw

}
 //是否现货IsStock
function IsStockFormat(isStockValue) {
    if (isStockValue == 1) {
        return "现货";
    } else if (isStockValue == 2) {
        return "定制";
    } else {
        return isStockValue;
    }
}
//货品状态格式化
function StatusFormat(statusValue) {
    if (statusValue == 0) {
        return "待查";
    } else if (statusValue == 1) {
        return "在库";
    } else if (statusValue == 2) {
        return "借出";
    } else if (statusValue == 3) {
        return "实验室";
    } else if (statusValue == 4) {
        return "保留";
    } else if (statusValue == 5) {
        return "展会";
    } else if (statusValue == 6) {
        return "报关中";
    } else if (statusValue == null) {
        return "";
    }
    return statusValue;
}

//所在地格式化
function PlaceFormat(place) {
	var placeText="";
    if (place == "HK") {
        placeText= "香港";
    } else if (place == "IND") {
        placeText= "印度";
    } else if (place == "CHN") {
        placeText= "国内";
    } else if (place == "UAE") {
        placeText= "阿联酋";
    } else if (place == "BEL") {
        placeText= "比利时";
    } else if (place == "ISR") {
        placeText= "以色列";
    } else if (place == "USA") {
        placeText= "美国";
    } else if (place == "JPN") {
        placeText="日本";
    } else if (place == "TL") {
        placeText="泰国";
    } else if (place == "SZ") {
        placeText="深圳";
    } else if (place == "SH") {
        placeText="上海";
    } else if (place == "BJ") {
        placeText="北京";
    } else if (place == "GZ") {
        placeText="广州";
    } else if (place == "UK") {
        placeText="英国";
    } else if (place == "GIA") {
       placeText="实验室";
    } else {
       placeText= place;
    }
    return _(placeText);
}
//日期格式化（月-日 时:分）
function DateTimeFormat(dateTimeValue) {
    if (dateTimeValue != null) {
        var CurrentDate = "";
        dateTimeValue = dateTimeValue.replace(/-/g,'/'); 
       dateTimeValue = dateTimeValue.replace(/T/g, ' ');//苹果手机浏览器浏览需加这个，不然会识别不了，变成NAN
       if(dateTimeValue.indexOf('.')>0){
       		dateTimeValue=dateTimeValue.substr(0,dateTimeValue.indexOf('.'))
       }
      var datetime = new Date(dateTimeValue);
		var Year = datetime.getFullYear();
        var Month = datetime.getMonth() + 1;
        var Day = datetime.getDate();
        var Hour = datetime.getHours();
        var Minute = datetime.getMinutes();		
		//CurrentDate += Year+"-";
        if (Month >= 10) {
            CurrentDate += Month + "-";
        }else {
            CurrentDate += "0" + Month + "-";
        }
        if (Day >= 10) {
            CurrentDate += Day + " ";
        }else {
            CurrentDate += "0" + Day + " ";
        }
        if (Hour >= 10) {
            CurrentDate += Hour + ":";
        }else {
            CurrentDate += "0" + Hour + ":";
        }

        if (Minute >= 10) {
            CurrentDate += Minute;
        }else {
            CurrentDate += "0" + Minute;
        }
        if (CurrentDate == "01-01 00:00") {
            CurrentDate = "";
        }
        return CurrentDate;//08-09 20:39
    } else {
        return "-";
    }
}
//订单状态格式化(客户)
function CustomerOrderStatusFormat(orderStatusValue) {
	var valueText="";
    if (orderStatusValue == 1) {
        valueText="待采购";
    } else if (orderStatusValue == 2) {
        valueText="待到货";
    } else if (orderStatusValue == 3) {
        valueText="待出货";
    } else if (orderStatusValue == 4) {
        valueText="已出货";
    } else if (orderStatusValue == 5) {
        valueText="已作废";
    } else if (orderStatusValue == 6) {
        valueText="退货成功";
    } else if (orderStatusValue == 7) {
        valueText="退货成功";
    }else{
    	valueText=orderStatusValue;
    }
    return _(valueText);
}
//收款状态格式化
function PaymentStatusFormat(paymentStatusValue) {
    if (paymentStatusValue != null) {
        if (paymentStatusValue == 1) {
            return "<b style='color:red;'>"+_("已收")+"</b>";
        } else if (paymentStatusValue == 0) {
            return _("未收");
        } else {
            return paymentStatusValue;
        }
    } else {
        return "-";
    }
}
//带链接的证书类型
function CertTypeFormat(row) {
    row.CertType = row.CertType ? row.CertType.toUpperCase() : "";
    //http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v1/certs/GIA/2224444063.pdf
    //http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v2/certs/GIA/2224444063.pdf  启用V2版本
    if (row.CertType && row.CertType != "") {
        if (row.CertNo && row.CertNo != "" && (row.CertType == "GIA" || row.CertType == "IGI")) {
            //var link = "<a href='http://www.checkgems.com/cert/" + row.CertType + "/" + row.CertNo + "' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";//有查宝网logo的链接
            //var link = "<a href='http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v2/certs/" + row.CertType + "/" + row.CertNo + ".pdf' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";//无查宝网logo的链接9-8
            var link = "<a  class='cert_link_btn' href='#' data-href='/team/ViewCert?certType=" + row.CertType + "&certNo=" + row.CertNo + "' title='证书查询" + row.CertNo + "'>" + row.CertType + "<img src='../Images/certNo_icon.svg' class='cert_link_img'></a>";
            // var link = "<a href='/team/ViewCert?certType=" + row.CertType + "&certNo=" + row.CertNo + "' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";
            return link;
        }
        else if (row.CertType == "HRD" || row.CertType == "NGTC" || row.CertType == "EGL") {
            return  row.CertType;
        }
        else if (row.CertType == "PARCEL") {
            return "PARCEL";//包货
        }
    }
    return  row.CertType;//无证书货-散货
}

//订单状态格式化(团队)
function UserOrderStatusFormat(orderStatusValue) {
	var valueText="";
	if (orderStatusValue == 0) {
        valueText="全部";
   } else if (orderStatusValue == 1) {
        valueText="待采购";
    } else if (orderStatusValue == 2) {
        valueText="待到货";
    } else if (orderStatusValue == 3) {
        valueText="待出货";
    } else if (orderStatusValue == 4) {
        valueText="已出货";
    } else if (orderStatusValue == 5) {
        valueText="已作废";
    } else if (orderStatusValue == 6) {
       valueText="已自留";
    } else if (orderStatusValue == 7) {
        valueText="已退回";
    } else if(orderStatusValue == 8){
    	valueText= "正常";
    }else if(orderStatusValue == 9){
    	valueText="异常";
    }else if(orderStatusValue == -1){
    	valueText="删除";
    }else{
    	valueText=orderStatusValue;
    }
    return _(valueText);
}
//付款状态格式化
function ReceiptStatusFormat(receiptStatusValue) {
    if (receiptStatusValue != null) {
        if (receiptStatusValue == 1) {
            return "<span style='color:red;'>"+_("已付")+"</span>";
        } else if (receiptStatusValue == 0) {
            return _("未付");
        } else if (receiptStatusValue == 2) {
            return "<span style='color:green;'>"+_("未清")+"</span>";
        } else {
            return receiptStatusValue;
        }
    } else {
        return "-";
    }
}
//截取字符串前10个
function StringFormat(stringValue) {
    if (stringValue == null) {
        return "";
    }
    return stringValue;
}

function ValueFormat(val) {
    if (val) {
        return val.toFixed(2);
    } else {
        return 0
    }
}
 
 //卖出人民币总价格式化
function ConfirmPriceFormat(confirmPriceValue){
    if (confirmPriceValue == null) {
        return "";
    }
    return confirmPriceValue;
}
//截取字符串前10个
    function StringFormat(stringValue) {
        if (stringValue == null) {
            return "";
        }
        return stringValue;
    }

//Null格式化为空白
function NullFormat(nullValue) {
    if (nullValue == null || nullValue=="") {
        return "-";
    }
    return nullValue;
}
//证书号格式化
    function CertNoFormat(certNoValue) {
        if (certNoValue ==null) {
            return "";
        }
        return certNoValue;
    }
     //卖出退点格式化
    function ConfirmdiscountFormat(confirmDiscountValue) {
        if (confirmDiscountValue == null) {
            return "-";
        }
        return confirmDiscountValue.toFixed(2);
    }

//卖出退点格式化 申请
function ConfirmdiscountFormatApply(confirmDiscountValue) {
    if (confirmDiscountValue == null) {
        return "-";
    }
    return confirmDiscountValue.toFixed(1);
}
     function DateFormat(dateValue) {
        if (!dateValue) return "-";

        var format = "MM-dd";
        var time1 = (dateValue + '').toString();
        dateValue = new Date(Date.parse(time1.replace(/-/g, "/").replace(/T|Z/g, ' ')));

        var o = {
            "M+": dateValue.getMonth() + 1, //月份
            "d+": dateValue.getDate(), //日
            "h+": dateValue.getHours(), //小时
            "m+": dateValue.getMinutes(), //分
            "s+": dateValue.getSeconds(), //秒
            "q+": Math.floor((dateValue.getMonth() + 3) / 3), //季度
            "S": dateValue.getMilliseconds() //毫秒
        };

        for (var k in o)
            if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

        return format;
    }
     //买入美金格式化
    function PriceUSDFormat(priceUSDValue) {
        if (priceUSDValue == null) {
            return 0;
        }
        return priceUSDValue;
    }
function Nullmat(value) {
    if (value == null) {
        return 0;
    }
    return parseInt(value);
}
//币种Currency格式化
function CurrencyFormat(currValue) {
    if (currValue == 1) {
        return _("人民币");
    } else if (currValue == 2) {
        return _("美元");
    } else if (currValue == null) {
        return "-";
    } else {
        return currValue;
    }
}

//奶油格式化
function MilkyFormat(milkyValue) {
    if (milkyValue) {
        var milky = milkyValue.toLowerCase();//不区分大小写
        if (milky == "ml4") {
            return _("重奶");
        } else if (milky == "ml3") {
            return _("中奶");
        } else if (milky == "ml2") {
            return _("轻奶");
        } else if (milky == "ml1") {
            return _("很轻奶");
        } else if (milky == "ml0") {
            return _("无奶");
        } else if (milky == "ml") {
            return _("带奶");
        } else if (milky == "na") {
            return _("待查");
        } else{ 
            return milkyValue;
        }
    } else {
        //Null
        return "";//null
    }        
    return milkyValue;
}
//色调格式化
function HueFormat(hueValue) {
    var huechn = "";
    if (hueValue) {
        var hue = hueValue.toLowerCase();//不区分大小写

        //咖br
        if (hue.indexOf("br") > -1) {
            if (hue.indexOf("br0") > -1) {
                huechn += "无咖 ";
            } else if (hue.indexOf("br1") > -1) {
                huechn += "轻微咖 ";
            } else if (hue.indexOf("br2") > -1) {
                huechn += "轻咖 ";
            } else if (hue.indexOf("br3") > -1) {
                huechn += "中咖 ";
            } else if (hue.indexOf("br4") > -1) {
                huechn += "大咖 ";
            } else if (hue.indexOf("br5") > -1) {
                huechn += "很大咖 ";
            } else if (hue.indexOf("br") > -1) {
                huechn += "有咖 ";
            }
        }
        //绿gr
        if (hue.indexOf("gr") > -1) {
            if (hue.indexOf("gr0") > -1) {
                huechn += "无绿 ";
            } else if (hue.indexOf("gr1") > -1) {
                huechn += "轻微绿 ";
            } else if (hue.indexOf("gr2") > -1) {
                huechn += "轻绿 ";
            } else if (hue.indexOf("gr3") > -1) {
                huechn += "中绿 ";
            } else if (hue.indexOf("gr4") > -1) {
                huechn += "大绿 ";
            } else if (hue.indexOf("gr5") > -1) {
                huechn += "很大绿 ";
            } else if (hue.indexOf("gr") > -1) {
                huechn += "有绿 ";
            }
        }
        if (hue.indexOf("mix") > -1) {
            huechn += "混色 ";
        }
        if (hue.indexOf("pk") > -1) {              
                huechn += "粉色 ";                
        }
        if (hue.indexOf("re") > -1) {
            huechn += "红色 ";
        }
        if (hue.indexOf("ye") > -1) {
            huechn += "黄色 ";
        }
        if (hue.indexOf("ow") > -1) {
            huechn += "灰白 ";
        }
        if (hue.indexOf("gy") > -1) {
            huechn += "灰色 ";
        }
        if (hue.indexOf("bl") > -1) {
            huechn += "蓝色 ";
        }
        if (hue.indexOf("or") > -1) {
            huechn += "橙色 ";
        }
        if (hue.indexOf("fy") > -1) {
            huechn += "彩色 ";
        }
        //包含na
        if (hue.indexOf("na") > -1) {
            huechn += "待查 ";
        }

        if (huechn != "") {
            return _(huechn);
        } else {
            return _(hueValue);
        }

    } else {
        return _("待查 ");//null
    }
    return hueValue;
}    

 //心箭格式化
function HAFormat(haValue) {
    if(haValue){
        var ha = haValue.toLowerCase();//不区分大小写

        if (ha == "id") {
            return _("理想");
        }else if(ha=="ex"){
            return _("极好");
        } else if (ha == "vg") {
            return _("很好");
        } else if (ha == "gd") {
            return _("较好");
        } else if (ha == "fr") {
            return _("一般");
        } else if (ha == "pr") {
            return _("较差");
        } else if (ha == "y") {
            return _("有");
        } else if (ha == "n") {
            return _("无");
        } else if (ha == "na") {
            return _("待查");
        } else if (ha == "") {
            return _("待查");
        } else {
            return haValue;
        }
    }else{
        return _("待查");//null
    }
    return haValue;
}
//黑点格式化 TSB TB  SB  BK
function BlackDefectFormat(blackDefectValue) {
    var blackchn = "";

    if (blackDefectValue) {
        var black = blackDefectValue.toLowerCase();//不区分大小写

        //包含na
        if (black.indexOf("na") > -1) {
            blackchn += _("待查");
        }

        //包含tsb
        if (black.indexOf("ts") > -1) {
            if (black.indexOf("tsb0") > -1) {
                blackchn += "台冠无黑 ";
            } else if (black.indexOf("tsb1") > -1) {
                blackchn += "台冠轻微黑 ";
            } else if (black.indexOf("tsb2") > -1) {
                blackchn += "台冠轻黑 ";
            } else if (black.indexOf("tsb3") > -1) {
                blackchn += "台冠中黑 ";
            } else if (black.indexOf("tsb4") > -1) {
                blackchn += "台冠大黑 ";
            } else if (black.indexOf("tsb") > -1) {
                blackchn += "台冠有黑 ";
            }
        }
        //包含tb
        if (black.indexOf("tb") > -1) {
            if (black.indexOf("tb0") > -1) {
                blackchn += "台无黑 ";
            } else if (black.indexOf("tb1") > -1) {
                blackchn += "台轻微黑 ";
            } else if (black.indexOf("tb2") > -1) {
                blackchn += "台轻黑 ";
            } else if (black.indexOf("tb3") > -1) {
                blackchn += "台中黑 ";
            } else if (black.indexOf("tb4") > -1) {
                blackchn += "台大黑 ";
            } else if (black.indexOf("tb") > -1) {
                blackchn += "台有黑 ";
            }
        }

        //包含sb
        if (black.indexOf("sb") > -1) {
            if (black.indexOf("sb0") > -1) {
                blackchn += "冠无黑 ";
            } else if (black.indexOf("sb1") > -1) {
                blackchn += "冠轻微黑 ";
            } else if (black.indexOf("sb2") > -1) {
                blackchn += "冠轻黑 ";
            } else if (black.indexOf("sb3") > -1) {
                blackchn += "冠中黑 ";
            } else if (black.indexOf("sb4") > -1) {
                blackchn += "冠大黑 ";
            } else if (black.indexOf("sb") > -1) {
                blackchn += "冠有黑 ";
            }
        }

        //包含bk
        if (black.indexOf("bk") > -1) {
            if (black.indexOf("bk0") > -1) {
                blackchn += "无黑 ";
            } else if (black.indexOf("bk1") > -1) {
                blackchn += "轻微黑 ";
            } else if (black.indexOf("bk2") > -1) {
                blackchn += "轻黑 ";
            } else if (black.indexOf("bk3") > -1) {
                blackchn += "中黑 ";
            } else if (black.indexOf("bk4") > -1) {
                blackchn += "大黑 ";
            } else if (black.indexOf("bk") > -1) {
                blackchn += "有黑 ";
            }
        }

        if (blackchn != "") {
            return _(blackchn);
        } else {
            return blackDefectValue;//11-23
        }

    } else {
        return _("待查 ");//null
    }
    return blackDefectValue;//11-23
}        
  //瑕疵格式化 TSI TI SI TSO TO SO OI I
function OtherDefectFormat(otherDefectValue) {
    var defectchn = "";

    if (otherDefectValue) {
        var defect = otherDefectValue.toLowerCase();//不区分大小写

        //包含na
        if (defect.indexOf("na") > -1) {
            defectchn += _("待查");
        }

        //里面
        //包含tsi
        if (defect.indexOf("tsi") > -1) {
            if (defect.indexOf("tsi0") > -1) {
                defectchn += "台冠无瑕 ";
            } else if (defect.indexOf("tsi1") > -1) {
                defectchn += "台冠轻微瑕 ";
            } else if (defect.indexOf("tsi2") > -1) {
                defectchn += "台冠轻瑕 ";
            } else if (defect.indexOf("tsi3") > -1) {
                defectchn += "台冠中瑕 ";
            } else if (defect.indexOf("tsi4") > -1) {
                defectchn += "台冠大瑕 ";
            } else if (defect.indexOf("tsi") > -1) {
                defectchn += "台冠有瑕 ";
            } 
        }
        //包含ti
        if (defect.indexOf("ti") > -1) {
            if (defect.indexOf("ti0") > -1) {
                defectchn += "台无瑕 ";
            } else if (defect.indexOf("ti1") > -1) {
                defectchn += "台轻微瑕 ";
            } else if (defect.indexOf("ti2") > -1) {
                defectchn += "台轻瑕 ";
            } else if (defect.indexOf("ti3") > -1) {
                defectchn += "台中瑕 ";
            } else if (defect.indexOf("ti4") > -1) {
                defectchn += "台大瑕 ";
            } else if (defect.indexOf("ti") > -1) {
                defectchn += "台有瑕 ";
            } 
        }
        //包含si
        if (defect.indexOf("si") > -1) {
            if (defect.indexOf("si0") > -1) {
                defectchn += "冠无瑕 ";
            } else if (defect.indexOf("si1") > -1) {
                defectchn += "冠轻微瑕 ";
            } else if (defect.indexOf("si2") > -1) {
                defectchn += "冠轻瑕 ";
            } else if (defect.indexOf("si3") > -1) {
                defectchn += "冠中瑕 ";
            } else if (defect.indexOf("si4") > -1) {
                defectchn += "冠大瑕 ";
            } else if (defect.indexOf("si") > -1) {
                defectchn += "冠有瑕 ";
            } 
        }              

        //表面

        //包含tso
        if (defect.indexOf("tso") > -1) {
            if (defect.indexOf("tso0") > -1) {
                defectchn += "台表无瑕 ";
            } else if (defect.indexOf("tso1") > -1) {
                defectchn += "台表轻微瑕 ";
            } else if (defect.indexOf("tso2") > -1) {
                defectchn += "台表轻瑕 ";
            } else if (defect.indexOf("tso3") > -1) {
                defectchn += "台表中瑕 ";
            } else if (defect.indexOf("tso4") > -1) {
                defectchn += "台表大瑕 ";
            } else if (defect.indexOf("tso") > -1) {
                defectchn += "台表有瑕 ";
            } 
        }

        //包含to
        if (defect.indexOf("to") > -1) {
            if (defect.indexOf("to0") > -1) {
                defectchn += "台表无瑕 ";
            } else if (defect.indexOf("to1") > -1) {
                defectchn += "台表轻微瑕 ";
            } else if (defect.indexOf("to2") > -1) {
                defectchn += "台表轻瑕 ";
            } else if (defect.indexOf("to3") > -1) {
                defectchn += "台表中瑕 ";
            } else if (defect.indexOf("to4") > -1) {
                defectchn += "台表大瑕 ";
            } else if (defect.indexOf("to") > -1) {
                defectchn += "台表有瑕 ";
            } 
        }

        //包含so
        if (defect.indexOf("so") > -1) {
            if (defect.indexOf("so0") > -1) {
                defectchn += "冠表无瑕 ";
            } else if (defect.indexOf("so1") > -1) {
                defectchn += "冠表轻微瑕 ";
            } else if (defect.indexOf("so2") > -1) {
                defectchn += "冠表轻瑕 ";
            } else if (defect.indexOf("so3") > -1) {
                defectchn += "冠表中瑕 ";
            } else if (defect.indexOf("so4") > -1) {
                defectchn += "冠表大瑕 ";
            } else if (defect.indexOf("so") > -1) {
                defectchn += "冠表有瑕 ";
            }
        }

        //包含oi
        if (defect.indexOf("oi") > -1) {
            if (defect.indexOf("oi0") > -1) {
                defectchn += "表无瑕 ";
            } else if (defect.indexOf("oi1") > -1) {
                defectchn += "表轻微瑕 ";
            } else if (defect.indexOf("oi2") > -1) {
                defectchn += "表轻瑕 ";
            } else if (defect.indexOf("oi3") > -1) {
                defectchn += "表中瑕 ";
            } else if (defect.indexOf("oi4") > -1) {
                defectchn += "表大瑕 ";
            } else if (defect.indexOf("oi") > -1) {
                defectchn += "表有瑕 ";
            }
        }

        //等于I
        if (defect == "i") {
            defectchn = "有瑕";
        } else if (defect == "i0") {
            defectchn = "无瑕";
        } else if (defect == "i1") {
            defectchn = "微瑕";
        } else if (defect == "i2") {
            defectchn = "小瑕";
        } else if (defect == "i3") {
            defectchn = "中瑕";
        } else if (defect == "i4") {
            defectchn = "大瑕";
        }

        if (defectchn != "") {
            return _(defectchn);
        } else {
            return otherDefectValue;
        }
    } else {
        //空
        return _("待查 ");//null
    }
    return otherDefectValue;
}        

 //所在地格式化
function PlaceFormat(place) {
    if (place =="HK") {
        return _("香港");
    } else if (place=="IND") {
        return _("印度");
    } else if (place == "CHN") {
        return _("国内");
    }else if (place == "UAE") {
        return _("阿联酋");
    }else if (place == "BEL") {
        return _("比利时");
    } else if (place == "UN") {
        return _("英国");
    } else if (place == "ISR") {
        return _("以色列");
    } else if (place == "USA") {
        return _("美国");
    } else if (place == "JPN") {
        return _("日本");
    } else if (place == "TL") {
        return _("泰国");
    } else if (place == "SZ") {
        return _("深圳");
    } else if (place == "SH") {
        return _("上海");
    } else if (place == "BJ") {
        return _("北京");
    } else if (place == "GZ") {
        return _("广州");
    } else if (place == "UK") {
        return _("英国");
    } else if (place == "GIA") {
        return _("实验室");
    }else if(place ==""){
        return "-";
    }else{
        return "-";
       }
}

function ShowImgOne(data) {
    if (data.Images) {
    	var firstImg = data.Images.split('|')[0]; //小图读第一张data.Images
        return "<img  src='" + firstImg + "' class='parcelimg ' alt='图片' style='width:100%' />";
    }
    else
        return "<img  src='../../Images/no_img.jpg' class='parcelimg ' alt='' style='width:100%;'/>";
}

function isIE() { //判断是否是ie浏览器，到最新版本
    if (!!window.ActiveXObject)
        return true;
    else
        return false;
}

    //日期时间格式化 03-09 dateTimeValue
    function DateTimeHandler(dateTimeValue) {
        if (dateTimeValue != null && dateTimeValue != "") {
            var timeStr = dateTimeValue.replace('T', ' ').replace(/-/g, '/'); //兼容firefox
            var hisTime = new Date(timeStr).getTime();
            if (!hisTime) { //数据库中可能为unicode时间
                timeStr = eval(dateTimeValue.replace(/\/(Date\([0-9-]+\))\//gi, 'new $1'));
                hisTime = new Date(timeStr).getTime();
            }
            var now = new Date().getTime(),
                diffValue = now - hisTime,
                result = '',
                minute = 1000 * 60,
                hour = minute * 60,
                day = hour * 24,
                halfamonth = day * 15,
                month = day * 30,
                year = month * 12,

                _year = diffValue / year,
                _month = diffValue / month,
                _week = diffValue / (7 * day),
                _day = diffValue / day,
                _hour = diffValue / hour,
                _min = diffValue / minute;

            if (_year >= 1) result = parseInt(_year) + _("年前");
            else if (_month >= 1) result = parseInt(_month) + _("月前");
            else if (_week >= 1) result = parseInt(_week) + _("周前");
            else if (_day >= 1) result = parseInt(_day) + _("天前");
            else if (_hour >= 1) result = parseInt(_hour) + _("小时前");
            else if (_min >= 1) result = parseInt(_min) + _("分钟前");
            else result = _("刚刚");
            return result;
        } else {
            return '';
        }
    }
    
        //状态格式化
        function sysStatusFormat(sysStatusValue) {
            if (sysStatusValue == -1) {
                return _("已删");
            } else if (sysStatusValue == 0) {
                return _("禁用");
            } else if (sysStatusValue == 2) {
                return _("待审");
            } else if (sysStatusValue == 1) {
                return _("正常");
            }
            return sysStatusValue;
        }

//角色格式化
function RoleIDFormat(roleIDValue) {
    if (roleIDValue == 1) {
        return "管理员";
    } else if (roleIDValue == 2) {
        return "会计员";
    } else if (roleIDValue == 3) {
        return "业务员";
    } else if (roleIDValue == 4) {
        return "采购员";
    } else if (roleIDValue == 5) {
        return "物流员";
    } else if (roleIDValue == 6) {
        return "副管";
    }else if(roleIDValue==7){
        return "业务经理";
    }else if(roleIDValue==8){
        return "顾问";
    } else if (roleIDValue == null) {
        return "";
    }
    return roleIDValue;
}
    
      //性别格式化
        function sexFormat(sexValue) {
            if (sexValue == 2) {
                return _("保密");
            } else if (sexValue == 1) {
                return _("男");
            } else if (sexValue == 0) {
                return _("女");
            }
            return sexValue;
        }
        

        //类型Type格式化
        function TypeFormat(typeValue) {
            if (typeValue == 1) {
                return _("收入");//+
            } else if (typeValue == 2) {
                return "<b style='font-weight:bold;color:red;'>"+_("支出")+"</b>";
            } else if (typeValue == null) {
                return "-";//-
            } else {
                return typeValue;
            }
        }
        
          //收支状态Status格式化
        function AccountStatusFormat(statusValue){
            if (statusValue == 1) {
                return _("已审核");
            } else if (statusValue == 0) {
                return "<b style='color:red;'>"+_("待审核")+"</b>";
            } else if (statusValue == -1) {
                return _("已作废");
            }else{
                return statusValue;
            }
        }

//格式成货币格式 12-19
function FormatMoney(number, places, symbol, thousand, decimal) {
    if (number != null) {
        number = number || 0;
        places = !isNaN(places = Math.abs(places)) ? places : 2;
        symbol = symbol !== undefined ? symbol : "";//$
        thousand = thousand || ",";
        decimal = decimal || ".";
        var negative = number < 0 ? "-" : "",
            i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
            j = (j = i.length) > 3 ? j % 3 : 0;
        return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
    } else {
        return "-";
    }
    return number;
}
        //摘要(操作)Abstract格式化
        function AbstractFormat(abstractValue){
        	var valueText="";
            if (abstractValue == 0) {
                valueText="订单付款";
            }else if (abstractValue == 1) {
                valueText="支付全款";
            } else if (abstractValue == 2) {
                valueText="客户充值";
            } else if (abstractValue == 3) {
               valueText="退供应商";
            }else if (abstractValue == 4) {
                valueText="自留变货";
            }else if (abstractValue == 5) {
                valueText="余额提现";
            }else if (abstractValue == 6) {
                valueText= "确认到货";
            }else if (abstractValue == 7) {
                valueText= "取消到货";
            }else if (abstractValue == 8) {
                valueText="申请收支";
            }else if (abstractValue == 9) {
                valueText="兑换美金";
            }else if (abstractValue == 10) {
                valueText= "直接充值";
            }else{
                valueText=abstractValue;
            }
            return _(valueText);
        }
        
        //用途Purpose格式化
        function PurposeFormat(purposeValue) {
            if (purposeValue == 1) {
                return _("裸钻");
            } 
            else if (purposeValue == 2) {
                return _("兑换");
            } 
            else if (purposeValue == 3) {
                return _("杂项");
            }
            else if (purposeValue == 4) {
                return _("借款");
            }
            else if (purposeValue == 5) {
                return _("还款");
            }            
            else {
                return purposeValue;
            }            
        }
        
        //类型Type格式化
        function TypeFormat(typeValue) {
            if (typeValue == 1) {
                return _("收入");//+
            } else if (typeValue == 2) {
                return "<b style='font-weight:bold;color:red;'>"+_("支出")+"</b>";
            } else if (typeValue == null) {
                return "-";//-
            } else {
                return typeValue;
            }
        }

        //摘要(操作)Abstract格式化
        function AbstractFormat(abstractValue){
        	var valueText="";
            if (abstractValue == 0) {
               valueText="订单付款";
            }else if (abstractValue == 1) {
                valueText="支付全款";
            } else if (abstractValue == 2) {
                valueText="客户充值";
            } else if (abstractValue == 3) {
                valueText="退供应商";
            }else if (abstractValue == 4) {
                valueText="自留变货";
            }else if (abstractValue == 5) {
                valueText="余额提现";
            }else if (abstractValue == 6) {
                valueText="确认到货";
            }else if (abstractValue == 7) {
                valueText="取消到货";
            }else if (abstractValue == 8) {
                valueText="申请收支";
            }else if (abstractValue == 9) {
                valueText="兑换美金";
            }else if (abstractValue == 10) {
                valueText= "直接充值";
            }else{
               valueText=abstractValue;
            }
            return _(valueText);
        }
        //订单IDs格式化
        function OrderIDsFormat(orderIDsValue){
            if(orderIDsValue == null || orderIDsValue == ""){
                return "";
            }else{
                return "<a href='#'>"+_("详情")+"</a>";
            }
        }
        //形状格式化（通用
function ShapeFormat(shapeValue) {
	var valueText="";
    if (shapeValue == 1) {
       valueText="圆形";
    }  else if (shapeValue == 2) {
        valueText="公主方";
    } else if (shapeValue == 3) {
        valueText= "祖母绿";
    } else if (shapeValue == 4) {
        valueText= "雷迪恩";
    } else if (shapeValue == 5) {
        valueText="椭圆形";
    } else if (shapeValue == 6) {
       valueText="梨形";
    } else if (shapeValue == 7) {
       valueText="马眼形";
    }else if (shapeValue == 8) {
       valueText="心形";
    }  else if (shapeValue == 9) {
       valueText= "三角形";
    }else if (shapeValue == 10) {
        valueText= "垫形";
    } else if (shapeValue == 11) {
        valueText="其它";
    }else if (shapeValue == 12) {
       valueText="梯形";
    } else if (shapeValue == 13) {
        valueText= "直方";
    } else if (shapeValue == 14) {
        valueText= "组合";
    }else if(
    	valueText="其它"
    )
    return _(valueText);
}
    //货号格式化
    function SNFormat(sNValue) {
        if (sNValue == null) {
            return "";
        }
        return sNValue;
    }
//通过星期返回相应日期 weeks星期几列表
function GetDateByWeek(weeks) {
    
    if (weeks) {
        var arr;
        if (weeks.indexOf(":") > -1) {  //传过来是日期，不是星期
            return new Date(weeks).format("yyyy-MM-dd");
        }
        else if (weeks.indexOf(",") > -1) {
            weeks = weeks.split(',');
            arr = weeks.sort();
        }
        else {
            arr = weeks;
        }
        var date = new Date();
        var today = date.getDay();
        for (var i = 0; i < arr.length; i++) {
            //当前星期等于参数星期
            if (today == arr[i]) {
                return date.format("yyyy-MM-dd");
            }//当前星期小于参数星期
            else if (today < arr[i]) {
                return new Date(date.getFullYear(), date.getMonth(), date.getDate() + (arr[i] - today)).format("yyyy-MM-dd");
            }
            else {
                //如果到传递过来的星期最后一个都不符合，则直接调整到下个星期
                if (i == arr.length - 1) {
                    return new Date(date.getFullYear(), date.getMonth(), date.getDate() + (7 + (arr[0] - today))).format("yyyy-MM-dd");
                }
            }
        }
    }
    else
        return "-";
}
//格式化
Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1, //month 
        "d+": this.getDate(), //day 
        "h+": this.getHours(), //hour 
        "m+": this.getMinutes(), //minute 
        "s+": this.getSeconds(), //second 
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter 
        "S": this.getMilliseconds() //millisecond 
    }

    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }

    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}

//显示10个字符以内
function partShowSubstring(val){
	if(val){
		if(val.length>10){
			return val.substring(0,9);
		}else{
			return val;
		}
	}else{
		return "-";
	}
	
}
//日期格式化（月-日）
    function YearDateFormat(dateValue) {
        if (dateValue != null && dateValue!="") {
            var CurrentDate = "";
            var datetime = new Date(dateValue);
            var Year = datetime.getFullYear();
            var Month = datetime.getMonth() + 1;
            var Day = datetime.getDate();
           // CurrentDate += Year + "-";
            if (Month >= 10) {
                CurrentDate += Month + "-";
            }else {
                CurrentDate += "0" + Month + "-";
            }

            if (Day >= 10) {
                CurrentDate += Day + " ";
            }else {
                CurrentDate += "0" + Day + " ";
            }

         if (CurrentDate == "01-01 00:00") {
             CurrentDate = "";
         }
            return CurrentDate;//08-09 20:39

        } else {
            return "-";
        }
    }

//日期格式化（年-月-日）
function YearDateFormats(dateValue) {

    if (dateValue != null && dateValue !="" && dateValue !=undefined) {

        var CurrentDate = "";

        var datetime = new Date(dateValue);
 
        var Year = datetime.getFullYear();
        var Month = datetime.getMonth() + 1;
        var Day = datetime.getDate();

        CurrentDate += Year + "-";

        if (Month >= 10) {
            CurrentDate += Month + "-";
        }else {
            CurrentDate += "0" + Month + "-";
        }

        if (Day >= 10) {
            CurrentDate += Day + " ";
        }else {
            CurrentDate += "0" + Day + " ";
        }

        // if (CurrentDate == "01-01 00:00") {
        //     CurrentDate = "";
        // }

        return CurrentDate;//08-09 20:39

    } else {
        return "-";
    }
}
function formatDate(time) {
    if (time && time.length > 10) {
    	if(time == "1970-01-01 "){
    		time = "";
    	}else{
    		 var t=time.substring(2);
        	return t.substring(0, t.length - 3);
    	} 
    }
    return time;
}

//兼容IOS时间显示
function GetDateDiffTime(DiffTime) {
    //将xxxx-xx-xx的时间格式，转换为 xxxx/xx/xx的格式
    Time = DiffTime.replace(/\-/g, "/");
    return Time;
}

//清空选项
function clearProductBtn(){
    $(".search_btn_b").css("background-color","#a1a1a1");
    $(".search_btn_b").attr("disabled",true);
}
